package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.PurchaseBean;
import com.project.dao.IPurchaseDao;
import com.project.service.IPurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

/**
 * @author lyl
 * description:
 */
@Service
@Transactional
public class PurchaseServiceImpl implements IPurchaseService {
    @Autowired
    private IPurchaseDao iPurchaseDao;

    @Override
    public PageInfo<PurchaseBean> showInfoByPage(int pageNum, String supplierName, LocalDate startDate, LocalDate endDate) {
        PageHelper.startPage(pageNum, 3);
        PageInfo<PurchaseBean> info = PageInfo.of(iPurchaseDao.showInfoByPage(supplierName, startDate, endDate));
        return info;
    }

    @Override
    public PurchaseBean findPurchaseById(int purchaseId) {
        return iPurchaseDao.findPurchaseById(purchaseId);
    }
}
